<template>
    <el-dialog :title="editData.userName" :visible.sync="showInfo" width="320px" top="20vh">
        <el-form id="userDiag" :model="editData" label-width="40px">
            <el-form-item id="cellPhoneDiag" label="电话">
                <el-input v-model="editData.cellPhone"></el-input>
            </el-form-item>
            <el-form-item id="emailDiag" label="邮箱">
                <el-input v-model="editData.email"></el-input>
            </el-form-item>
            <el-form-item id="ticketUserNameDiag" label="账户">
                <el-input v-model="editData.ticketUserName"></el-input>
            </el-form-item>
            <el-form-item id="buttonLogin">
                <el-button style="width:120px; margin-top: 8px" type="primary" @click="editUser()">完成</el-button>
            </el-form-item>
        </el-form>
    </el-dialog>
</template>

<script>
    let infoData = {
        status: 1,
        message: '',
        userName: '',
        cellPhone: '',
        email: '',
        wxOpenId: '',
        ticketUserName: ''
    }

    function getCurDate() {
        const utcMs = Date.now();
        const now = new Date(utcMs + 3600000 * 8);

        const date = now.toDateString();
        return date;
    }

    export default {
        infoData,

        created: function () {
            this.editData = JSON.parse(JSON.stringify(infoData));
        },

        methods: {
            // 显示用户信息
            showUser: function showUser() {
                if (this.isLogin) {
                    this.editData = JSON.parse(JSON.stringify(infoData));
                    this.showInfo = true;
                } else {
                    this.$message({
                        title: '警告',
                        message: '用户未登录！',
                        type: 'warning'
                    });
                }
            },

            // 修改用户信息
            editUser: function editUser() {
                infoData = JSON.parse(JSON.stringify(this.editData));
                this.showInfo = false;
            }
        },

        data() {
            return {
                showInfo: false,
                isLogin: true,

                editData: {},
            }
        }
    }

</script>

<style>
    #userDiag {
        width: 99%;
    }

</style>

